/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AgregarAcompanante.java
 *
 * Created on 23/06/2010, 09:08:07 PM
 */

package CapaGrafica;
import CapaLogica.Operaciones;
/**
 *
 * @author Maria
 */
public class AgregarAcompanante extends javax.swing.JFrame {
    private MenuUsuario ventanaMadre;
    private String nombre;
    private String cedula;
    private String idReserva;
    private String formaPago;
    private String fechaActual;

    /** Creates new form AgregarAcompanante */
    public AgregarAcompanante(MenuUsuario ventana, String nombre, String cedula, String idReserva, String formaPago, String fechaActual) {
        initComponents();
        this.ventanaMadre = ventana;
        this.nombre = nombre;
        this.cedula = cedula;
        this.idReserva = idReserva;
        this.formaPago = formaPago;
        this.fechaActual = fechaActual;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jBsi = new javax.swing.JButton();
        jBno = new javax.swing.JButton();
        jLmensaje = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jBsi.setText("agregar");
        jBsi.setName("jBsi"); // NOI18N
        jBsi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBsiActionPerformed(evt);
            }
        });

        jBno.setText("listo");
        jBno.setName("jBno"); // NOI18N
        jBno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBnoActionPerformed(evt);
            }
        });

        jLmensaje.setText("jLabel1");
        jLmensaje.setName("jLmensaje"); // NOI18N

        jSeparator1.setName("jSeparator1"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(64, 64, 64)
                .addComponent(jBsi)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 121, Short.MAX_VALUE)
                .addComponent(jBno, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(75, 75, 75))
            .addGroup(layout.createSequentialGroup()
                .addGap(157, 157, 157)
                .addComponent(jLmensaje)
                .addContainerGap(209, Short.MAX_VALUE))
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(69, 69, 69)
                .addComponent(jLmensaje)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 85, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBsi, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBno))
                .addGap(71, 71, 71))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBsiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBsiActionPerformed
      ControlDeAcompanantes ventana = new ControlDeAcompanantes
                (this, cedula, idReserva);

        this.setVisible(false);
        ventana.setVisible(true);  // TODO add your handling code here:
    }//GEN-LAST:event_jBsiActionPerformed

    private void jBnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBnoActionPerformed
      imprimirFactura();  // TODO add your handling code here:
    }//GEN-LAST:event_jBnoActionPerformed

    /**
    * @param args the command line arguments
    */
    

public void imprimirFactura() {
        boolean facturaGenerada;

        do
        {
            facturaGenerada = Operaciones.generarFactura(this, nombre, cedula, idReserva, formaPago, fechaActual);
        }
        while (!facturaGenerada);

        ventanaMadre.setVisible(true);
        this.dispose();
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBno;
    private javax.swing.JButton jBsi;
    private javax.swing.JLabel jLmensaje;
    private javax.swing.JSeparator jSeparator1;
    // End of variables declaration//GEN-END:variables

}
